import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;

import javax.swing.*;

public class Windows7Calculator extends JFrame implements ActionListener {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	JMenuItem fileItem1;
	private JLabel jlbOutput;
	JButton btn;
	private JPanel jplOutput,jplMaster;
	
	
	Font f12 = new Font("Times New Roman", 0, 12);
	Font f121 = new Font("Times New Roman", 1, 12);

	
	
	public Windows7Calculator(){
		//JFrame frame= new JFrame("Calculator");
		
		
		jplMaster = new JPanel();
		
		// create menubar, menu & submenu.
		JMenuBar menuBar= new JMenuBar();
		//menuBar.setBackground(Color.);
		
		JMenu fileMenu= new JMenu("File");
		fileMenu.setFont(f121);
		fileMenu.setMnemonic(KeyEvent.VK_F);
		//fileMenu.add(new JSeparator());
		
		JMenu editMenu= new JMenu("Edit");
		editMenu.setFont(f121);
		editMenu.setMnemonic(KeyEvent.VK_E);
		//editMenu.add(new JSeparator());
		
		fileItem1= new JMenuItem("Close");
		fileItem1.setFont(f12);
		fileItem1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L,ActionEvent.CTRL_MASK));
		//fileItem1.add(new JSeparator());
		JMenuItem editItem1= new JMenuItem("Cut");
		editItem1.setFont(f12);
		editItem1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X,ActionEvent.CTRL_MASK));
		
		JMenuItem editItem2= new JMenuItem("Copy");
		editItem2.setFont(f12);
		editItem2.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,ActionEvent.CTRL_MASK));
		JMenuItem editItem3= new JMenuItem("Paste");
		editItem3.setFont(f12);
		editItem3.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V,ActionEvent.CTRL_MASK));
		
		fileMenu.add(fileItem1);
		editMenu.add(editItem1);
		editMenu.add(editItem2);
		editMenu.add(editItem3);
		
		menuBar.add(fileMenu);
		menuBar.add(editMenu);
		
		setJMenuBar(menuBar);
		
//		jlbOutput = new JLabel("0");
//		jlbOutput.setHorizontalTextPosition(JLabel.RIGHT);
//		jlbOutput.setSize(280, 50);		
//		jlbOutput.setBackground(Color.WHITE);
//		jlbOutput.setOpaque(true);
//		
//		jplOutput= new JPanel();
//		jplOutput.add(jlbOutput);
		
		// Add components to frame
		//getContentPane().add(jlbOutput, BorderLayout.NORTH);
		
		
//		jplMaster.setLayout(new BorderLayout());
//		
//		jplMaster.add(jplOutput, BorderLayout.SOUTH);
//		
//		getContentPane().add(jplMaster, BorderLayout.SOUTH);
//		requestFocus();
//		
		JPanel panel = new JPanel();

        panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
        panel.setLayout(new GridLayout(5, 4, 5, 5));

        String[] buttons = {
            "C", "B","","", "7", "8", "9", "/", "4",
            "5", "6", "*", "1", "2", "3", "-", "0", ".", "=", "+"
        };


        for (int i = 0; i < buttons.length; i++) {

            if (i == 2)
                panel.add(new JLabel(buttons[i]));
          
           
           
            
            else
                panel.add(new JButton(buttons[i]));
           
          
        }

        add(panel);
        
        jplMaster.setLayout(new BorderLayout());
		jplMaster.add(panel, BorderLayout.WEST);
		

		// Add components to frame
		getContentPane().add(jplMaster, BorderLayout.SOUTH);
		
		
		
		fileItem1.addActionListener(this);
	}
		
		public static void main(String args[]){
			Windows7Calculator w=new Windows7Calculator();
			//Container contentPane = w.getContentPane();
			w.setTitle("Calculator");
			w.setBackground(Color.gray);
			w.setSize(320,320);
			//w.setSize(230, 320);
			//w.pack();
			w.setLocation(400, 250);
			w.setVisible(true);
			w.setIconImage(Toolkit.getDefaultToolkit().getImage("D://CalculatorImage//calculator-12.png"));
			w.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
			w.setResizable(false);	
			
		}
	

	@Override
	public void actionPerformed(ActionEvent e) {
		
		if (e.getSource()==fileItem1){
			System.exit(0);
			
		}
		
	}
}


